#! /bin/sh /usr/share/dpatch/dpatch-run
## 78_7775_various_caption_fixes.dpatch by  <root@mythserver.home.rodriguez-vudoyra.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/NuppelVideoPlayer.cpp mythtv-0.22.0-fixes22994/libs/libmythtv/NuppelVideoPlayer.cpp
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/NuppelVideoPlayer.cpp	2009-12-22 21:27:37.000000000 -0600
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/NuppelVideoPlayer.cpp	2009-12-22 21:30:02.000000000 -0600
@@ -7866,6 +7866,9 @@
         if ((1<<i) & window_map)
             GetCCWin(service_num, i).visible = true;
     }
+
+    if (GetOSD())
+        GetOSD()->CC708Updated();
 }
 
 void NuppelVideoPlayer::HideWindows(uint service_num, int window_map)
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/cc708window.cpp mythtv-0.22.0-fixes22994/libs/libmythtv/cc708window.cpp
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/cc708window.cpp	2009-12-22 21:27:37.000000000 -0600
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/cc708window.cpp	2009-12-22 21:42:09.000000000 -0600
@@ -155,7 +155,22 @@
     true_row_count    = (row_lock) ? row_count : max(row_count + 1, (uint)2);
     true_column_count = column_count;
 
-    if (text && (!exists || (old_row != true_row_count) ||
+    if (text && exists && (old_col == true_column_count)
+                       && (old_row < true_row_count))
+    {
+        // We need to add more rows to an existing window
+        uint num = true_row_count * true_column_count;
+        CC708Character *new_text = new CC708Character[num];
+        pen.column = 0;
+        pen.row = 0;
+        for (uint i = 0; i < old_row * old_col; i++)
+            new_text[i] = text[i];
+        for (uint i = old_row * old_col; i < num; i++)
+            new_text[i].attr = pen.attr;
+        delete [] text;
+        text = new_text;
+    }
+    else if (text && (!exists || (old_row != true_row_count) ||
                  (old_col != true_column_count)))
     {
         delete [] text;
@@ -367,12 +382,12 @@
     if (k708DirLeftToRight == print_dir || k708DirRightToLeft == print_dir)
     {
         // basic wrapping for l->r, r->l languages
-        if (new_column >= (int)true_column_count)
+        if (!row_lock && column_lock && (new_column >= (int)true_column_count)) 
         {
             new_column  = 0;
             new_row    += 1;
         }
-        else if (new_column < 0)
+        else if (!row_lock && column_lock && (new_column < 0)) 
         {
             new_column  = (int)true_column_count - 1;
             new_row    -= 1;
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.cpp mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.cpp
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.cpp	2009-10-14 20:32:47.000000000 -0500
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.cpp	2009-12-22 21:37:57.000000000 -0600
@@ -2729,6 +2729,8 @@
                         const CC708Window &win,
                         const vector<CC708String*> &list)
 {
+    if (!win.visible) return;
+ 
     int maxx = surface->width;
     int maxy = surface->height;
     uint max_width = 0, total_height = 0, i = 0;
